import { apiGet, apiPost, apiPut, apiDelete } from './client'

export interface ScoreDetail {
  id?: number
  studentId?: number
  offeringId?: number
  itemId?: number
  score?: number
  absentFlag?: number
  deferredFlag?: number
  cheatFlag?: number
  remark?: string
}

export async function listScoreDetails(params: { offeringId: number; studentId: number }) {
  return apiGet<ScoreDetail[]>('/api/grades/scores/detail', params)
}

export async function createScoreDetail(detail: ScoreDetail) {
  return apiPost<ScoreDetail>('/api/grades/scores/detail', detail)
}

export async function updateScoreDetail(id: number, detail: ScoreDetail) {
  return apiPut<ScoreDetail>(`/api/grades/scores/detail/${id}`, detail)
}

export async function deleteScoreDetail(id: number) {
  return apiDelete<string>(`/api/grades/scores/detail/${id}`)
}